package WinterFlower.work0715.exampleclass;

import java.util.Scanner;

/**
 * @author ZJM
 * @version 1.0
 * @since 2022-07-15 18:58:15
 */
public class StringEX03 {
    public static void main(String[] args) {
//  找出数字和 是指定n 的 所有五位或者六位的数字

       Scanner sc = new Scanner(System.in);
       int o = sc.nextInt();
        for (int i = 10000; i <= 999999; i++) {
            if (isPalindromes(i) ||isPalindromes2(i)) {
                if(isSum(i) == o){
                    System.out.println(i);
                }
                }
            }


        }



    public static boolean isPalindromes(int number) {
        String str = String.valueOf(number);
        char[] c = str.toCharArray();//将此字符串转换为新的字符数组
        int length = c.length;
        if (length == 5) {
            if (c[0] == c[4] & c[1] == c[3]) {
                return true;
            }
            else{
                return false;
            }
        }
        return false;
    }
    public static boolean isPalindromes2(int number) {
        String str = String.valueOf(number);
        char[] c = str.toCharArray();//将此字符串转换为新的字符数组
        int length = c.length;
        if (length == 6) {
            if (c[0] == c[5] & c[1] == c[4] & c[2] == c[3]) {
                return true;
            }

        }
        return false;
    }



    public static int isSum(int n) {
        int sum = 0;
        while (n != 0) {
            sum += (n % 10);
            n /= 10;
    }
        return sum;

}
}